<template>
    <div>
        <el-breadcrumb separator=">" class="mianbao">
            <el-breadcrumb-item :to="{ path: '/allStore' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item><a href="/">用户管理</a></el-breadcrumb-item>
            <el-breadcrumb-item>未审核</el-breadcrumb-item>
        </el-breadcrumb>
        <el-table :data="tableData" style="line-height:20px">
            <el-table-column prop="id" label="用户id" width="140"></el-table-column>
            <el-table-column prop="username" label="用户名" width="140"></el-table-column>
            <el-table-column prop="shopname" label="店铺名称" width="120"></el-table-column>
            <!-- :formatter="realsex" -->
            <el-table-column prop="phone" label="店铺手机号"  width="120"></el-table-column>
            <el-table-column prop="shopAddress" label="店铺所在地址"></el-table-column>
            <el-table-column label="经营许可证"  width="120">
                <template slot-scope="scope">
                    <img :src="scope.row.certificate" width="40" height="40" class="head_pic"/>
                </template>
            </el-table-column>
            <el-table-column label="用户头像"  width="120">
                <template slot-scope="scope">
                    <img :src="scope.row.headpicture" width="40" height="40" class="head_pic"/>
                </template>
            </el-table-column>
            <el-table-column label="店铺照片"  width="120">
                <template slot-scope="scope">
                    <img :src="scope.row.shoppicture" width="40" height="40" class="head_pic"/>
                </template>
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <!-- <router-link :to="'/usersEdit/'+scope.row.id">
                        <el-button type="primary" size="mini" >编辑</el-button>
                    </router-link> -->
                    <el-button size="mini" type="danger" @click="updateState(scope.row)">批准</el-button>
                    <!-- <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button> -->
                </template>
            </el-table-column>
        </el-table>
        <div class="block" style="text-align: center">
            <el-pagination
            @current-change="handleCurrentChange"
            :current-page.sync="pageNum"
            :page-size="10"
            layout="total, prev, pager, next"
            :total="list.length">
            </el-pagination>
        </div>
    </div>    
</template>

<script>
import users from '@/api/users.js';
export default {
    data(){
        return{
            // realsex:'男',
            tableData:[],
            list:[],
            pageNum:1
        }
    },
    methods:{
        findAll(){
            users.findAllUnaudited().then((response)=>{
                console.log(response);
                // this.tableData = response.data.data;
                this.list = response.data.data;
                this.tableData = this.list.slice(this.pageNum-1,10)
            })
        },
        handleCurrentChange(val) {
            this.pageNum = val;
            this.tableData = this.list.slice((this.pageNum-1)*10,this.pageNum*10)
        },
        updateState(row){
            console.log(row.id);
            console.log(row.sid);
            users.updateStoreStateBy(row.id,row.sid).then((response)=>{
                console.log(response.data)
                if(response.data.data==1){
                    this.findAll();
                }
            })
        },
    },
    created(){
        this.findAll();
    }
}
</script>

<style scoped>

</style>